package com.jumper.cwolf.leetcode;

import java.util.Arrays;

/**
 * 描述：
 *
 * @author cwolf
 * @version 1.0
 * @date 2021/4/2 11:18
 */
public class CodeLCP28 {

    public int purchasePlans(int[] nums, int target) {
        Arrays.sort(nums);
        long size = 0;
        int preQ = nums.length-1;
        for(int i=0;i<nums.length;i++){
            int n = nums[i];
            if(n>=target){
                break;
            }
            for(int q=preQ;q>=i+1;q--){
                int qn = nums[q];
                if(qn+n<=target){
                    size = size+q-i;
                    break;
                }
                preQ = q;
            }
        }
        return (int) (size%1000000007);
    }

//        System.out.println("nums:"+JSONUtil.toJsonStr(nums));

    public static void main(String[] args) {
        System.out.println(4999950000L%1000000007);
        int[] arr = new int[100000];
        for(int i=0;i<100000;i++){
            arr[i] = 1;
        }
         int trap       = new CodeLCP28().purchasePlans(arr,2);
        System.out.println(trap);
    }

}
